{include file="public/com_header"}

<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li><a href="{:url('admin/urlsconfig/index')}" class="a_menu">URL美化管理</a></li>
        <li class="layui-this">新增美化</li>
      </ul>
    </div>
    <div style="margin-top: 20px;">
    </div>
    <form class="layui-form" id="admin">

      <div class="layui-form-item">
        <label class="layui-form-label">美化前url</label>
        <div class="layui-input-inline">
          <input name="url" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$urlconfig.url"}value="{$urlconfig.url}"{/notempty}>
        </div>
        <div class="layui-form-mid layui-word-aux">例：admin/common/login</div>
      </div>

      <div class="layui-form-item">
        <label class="layui-form-label">美化后url</label>
        <div class="layui-input-inline">
          <input name="aliases" autocomplete="off" placeholder="请输入" class="layui-input" type="text" {notempty name="$urlconfig.aliases"}value="{$urlconfig.aliases}"{/notempty}>
        </div>
        <div class="layui-form-mid layui-word-aux">例：login(如有参数：login/:id)</div>
      </div>

      <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block" style="max-width:400px;">
          <textarea placeholder="请输入内容" class="layui-textarea" name="desc">{notempty name="$urlconfig.desc"}{$urlconfig.desc}{/notempty}</textarea>
        </div>
      </div>
      
      {notempty name="$urlconfig"}
      <input type="hidden" name="id" value="{$urlconfig.id}">
      {/notempty}
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
      </div>
      
    </form>


    <!--<script src="__PUBLIC__/layui/layui.js"></script>-->
    <!--<script src="__PUBLIC__/jquery/jquery.min.js"></script>-->
    <!--<script>-->
        <!--var message;-->
        <!--layui.config({-->
            <!--base: '__JS__/',-->
            <!--version: '1.0.1'-->
        <!--}).use(['app', 'message'], function() {-->
            <!--var app = layui.app,-->
                <!--$ = layui.jquery,-->
                <!--layer = layui.layer;-->
            <!--//将message设置为全局以便子页面调用-->
            <!--message = layui.message;-->
            <!--//主入口-->
            <!--app.set({-->
                <!--type: 'iframe'-->
            <!--}).init();-->
        <!--});-->
    <!--</script>-->
    {include file="public/com_js"}

    <script>
      layui.use(['layer', 'form'], function() {
          var layer = layui.layer,
              $ = layui.jquery,
              form = layui.form;
          $(window).on('load', function() {
              form.on('submit(admin)', function(data) {
                  $.ajax({
                      url:"{:url('admin/urlsconfig/publish')}",
                      data:$('#admin').serialize(),
                      type:'post',
                      async: false,
                      success:function(res) {
                          if(res.code == 1) {
                              layer.alert(res.msg, function(index){
                                location.href = res.url;
                              })
                          } else {
                              layer.msg(res.msg);
                          }
                      }
                  })
                  return false;
              });
          });
      });
    </script>
  </div>
</body>
</html>